package com.lianxi

/**
  * Created by adengdeng on 2017/8/5 
  */
object Lx10 {

  def func(x: Double, n: Int): Double = {
    if (n > 0)
      if (n % 2 == 0)
        func(x, n / 2) * func(x, n / 2)
      else
        x * func(x, n - 1)
    else if (n < 0) 1 / func(x, -n)
    else 1
  }

  def main(args: Array[String]): Unit = {
    println(func(2, -3))
  }
}
